# -*- coding: utf-8 -*-

def asfloat(f, default=''):
    try:
        f = float(f)
        return '{:>8.2f}'.format(f)
    except ValueError:
        if default:
            return default
        return f

def guid(self, mlen=16, kind='mix'):
    up = [chr(i) for i in range(65, 91)]
    down = [chr(i) for i in range(97, 123)]
    num = [chr(i) for i in range(48, 58)]
    src = up + down + num
    if kind == 'str':
        src = up + down
    elif kind == 'num':
        src = num
    elif kind == 'mix':
        src = up + down + num
    psw = ''.join([random.choice(src) for i in range(1, mlen)])
    while psw[0] == 0:
        psw[0] = random.choice(src)
    return psw

